package com.hnchances.controller;


import com.hnchances.common.vo.ResultVo;
import com.hnchances.entity.Grades;
import com.hnchances.entity.vo.GradeVo;
import com.hnchances.service.GradesService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigInteger;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author testjava
 * @since 2022-08-11
 */
@RestController
@RequestMapping("/grades")
public class GradesController {

    @Autowired
    private GradesService gradesService;

    @ApiOperation("成绩添加接口")
    @PostMapping("/add")
    public ResultVo add(@RequestBody Grades grades){
       return gradesService.add(grades);
    }

    @ApiOperation("成绩删除接口")
    @PostMapping("/del/{gradeId}")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="BigInteger",name = "gradeId",value = "成绩单Id",required = true)
    })
    public ResultVo del(@PathVariable BigInteger gradeId){
        return gradesService.delete(gradeId);
    }


    @ApiOperation("成绩更新接口")
    @PostMapping("/update")
    public ResultVo update(@RequestBody Grades grades){
        return gradesService.updateGrade(grades);
    }


    @ApiOperation("成绩查询接口")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "Integer",name = "pageNum",value = "第几页",required = true),
            @ApiImplicitParam(paramType="Integer",name = "pageSize",value = "分页大小",required = true)
    })
    @PostMapping("/select")
    public ResultVo select(@RequestBody GradeVo gradevo,Integer pageNum,Integer pageSize){
        return gradesService.select(gradevo,pageNum,pageSize);
    }

}

